﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Mail;

namespace MVCBugTracker.Models
{
    public class SmtpMailDeliveryService : IMailDeliveryService
    {
        public MailDeliveryResult Send(string recipientEmail, MailMessage message)
        {
            message.To.Clear();
            message.To.Add(recipientEmail);

            SmtpClient client = new SmtpClient();
            // Get config from smtp.config
            try
            {
                client.Send(message);
                return new MailDeliveryResult()
                {
                    Success = true
                };
            }
            catch (Exception ex)
            {
                return new MailDeliveryResult()
                {
                    Success = false,
                    Exception = ex
                };
            }
        }
    }
}